package com.wlc.fanxing;

import com.wlc.collection.Hero;
import com.wlc.oop.demo08.Item;

import java.util.LinkedList;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description HeroStack
 * @date 2021-07-13 15:40
 */
public class ItemStack {

    LinkedList<Item> heros = new LinkedList<Item>();

    public void push(Item h) {
        heros.addLast(h);
    }

    public Item pull() {
        return heros.removeLast();
    }

    public Item peek() {
        return heros.getLast();
    }

    public static void main(String[] args) {

        ItemStack heroStack = new ItemStack();
        for (int i = 0; i < 5; i++) {
            Item h = new Item("item name " + i);
            System.out.println("压入 item:" + h);
            heroStack.push(h);
        }
        for (int i = 0; i < 5; i++) {
            Item h =heroStack.pull();
            System.out.println("弹出 item" + h);
        }
    }

}
